<!-- login -->
<template>
    <div class="login">
        <h1>用户登录</h1>
        <transition>
            <div class="form">
                账号：<input type="text" v-model="username"><br>
                密码：<input type="password" v-model="password"><br>
                <button @click="login">登录</button>
            </div>
        </transition>
    </div>
</template>
  

<script setup>
import {ref,onMounted} from 'vue' 
import { useRouter,useRoute } from 'vue-router';
const username=ref('')
  const password=ref('')
  const router = useRouter()
  const route =useRoute()
  const login=()=>{
    const userInfo=JSON.parse(window.localStorage.getItem('userInfo'))
    if(userInfo){
      if (userInfo.username == username.value && userInfo.password == password.value) {
      window.localStorage.setItem('token',username.value +password.value)
      router.push('/')
    }else{
      alert('用户名或密码不正确')
    }
  }else{
    alert('用户未注册')

    }
  }
  onMounted(() => {
    username.value =route.query.username
    password.value=route.query.password
  })


</script>
<style>
@media (min-width: 1024px) {
    .about {
        min-height: 100vh;
        display: flex;
        align-items: center;
    }
}
</style>
  